@echo off
title Deploying VBEN...
echo Deploying VBEN...

echo.
echo "Switch Node Version.............."
call nvm use 20

echo.
echo "Git Pull.............."
cd ..\..
git pull

echo.
echo "PNPM Build.............."
call pnpm run build:antd

echo.
echo "Copy File.............."
rd .\k8s\uat\dist /S /Q
xcopy .\apps\web-antd\dist .\k8s\uat\dist /E /I

cd .\k8s\uat

echo.
echo "ACR Login.............."
call az acr login -n regwmsuat
pause

echo.
echo "Image Build.............."
docker build -t regwmsuat.azurecr.io/awanp3/vben5:latest .

echo.
echo "Image Push.............."
docker push regwmsuat.azurecr.io/awanp3/vben5:latest

echo.
echo "K8s Deploy.............."
kubectl apply -f .\deployment.yml
kubectl rollout restart deployment deployment-vben5 -n awanp3
timeout /nobreak /t 5

echo.
echo "Delete Image.............."
docker rmi regwmsuat.azurecr.io/awanp3/vben5:latest
pause
